package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface PermissionDao {

    @Select("select p.* from t_permission p,t_role_permission rp where p.id = rp.permission_id and rp.role_id = #{role_id}")
    public Set<Permission> findByRoleId(Integer roleId);

    @Select("select * from t_permission")
    List<Permission> findAll();

    Page<CheckGroup> findByCondition(String queryString);


    void add(Permission permission);

    void edit(Permission permission);

    @Select("select * from t_permission where id=#{id}")
    Permission findById(Integer id);

    @Delete("delete from t_permission where id=#{id}")
    void deleteById(Integer id);

    @Select("select count(*) from t_role_permission where permission_id = #{id}")
    long findCountPermissionId(Integer id);
}
